<script type="text/javascript">
    var page = 0;
    function showMore() {
        page++;
        $.ajax({
            url: "<?=site_url('home/moreSearch/'.$keyword)?>/" + page+'?type='+"<?=$type?>",
            success: function(res){
                var result = $.parseJSON(res);
                if(result.status ==false){
                    alert('Không tìm thấy kết quả phù hợp!');
                }else{
                    //window.location.hash = '#mores-' + page;
                    $('#moreTopic').append(result.list.trim());
                    //$('#loader').hide();
                } 
            }
        });
    }
</script>
<section id="search">
        <form name="search_op" id="search_op">
            <input id="keyword_ops" value="<?=$keyword?>" type="text">
            <button type="submit">Tìm kiếm</button>
            <ul class="options">
                <li>
                    <label>
                    <input checked="checked" name="options_s" value="0" type="radio">
                    Tìm tất cả</label>
                </li>
                <li>
                    <label>
                    <input name="options_s" value="1" type="radio">
                    Tìm theo tiêu đề</label>
                </li>
                <li>
                    <label>
                    <input name="options_s" value="3" type="radio">
                    Tìm theo nội dung</label>
                </li>
            </ul>
        </form>
<script type="text/javascript">
        $(document).ready(function () {
            $("input[name='options_s'][value='0']").attr("checked", true);
            $('#search_op').submit(function () {
                var url = "<?=site_url('home/search').'/'?>";
                var keyword = $('#keyword_ops').val();
                if (keyword != '' && keyword != 'Nhập nội dung cần tìm') {
                    //keyword = keyword.replace(" ", "-");
                    url += encodeURIComponent(keyword);
                }
                var selected = $("input[type='radio'][name='options_s']:checked");
                if (selected.length > 0 && selected.val() > 0)
                    url += "?type=" + selected.val();
                else url += "?type=0";

                window.location = url;
                return false;
            });
        });
</script>
<section class="content-wrap">

        <section class="result top">
                <header>

                    <h1>Bài viết về <a href="#" title="<?=$keyword?>"><?=$keyword?></a></h1>
                    <p class="count"> <?php if($total >0){ ?>Hiển thị <span>5</span> trong <?=$total; } else echo 'Hiện có 0';?> kết quả</p>

                </header>
                <?php 
                    if($searchTopic){
                        foreach ($searchTopic as $topic) {
                            # code...
                ?>

                <article class="<?php
                                if ($topic->topic_news_type == "video") {
                                    echo "hasvideo";
                                } elseif ($topic->topic_news_type == "picture") {
                                    echo "picture";
                                } else {
                                    echo "";
                                }
                                ?>">
                        <p class="type"></p>
                        <div class="cover" style="background-image: url(<?php echo $topic->topic_news_picture;?>)">
                                <a href="<?=site_url('home/detail').'/'.$topic->topic_news_id?>"></a>
                        </div>
                        <header>
                                <h1>
                                <a href="<?=site_url('home/detail').'/'.$topic->topic_news_id?>">
                                <?=$topic->topic_news_title?>
                                </a>

                                </h1>
                                <time datetime="<?=date('Y-m-d H:i:s', $topic->topic_news_date)?>"></time>
                                <p class="cate"><?php 
                                    $CI = & get_instance();
                                    $CI->load->model('category_model');
                                    $cate = $CI->category_model->getInfo($topic->category_id);
                                echo $cate->category_name;?></p>
                                <p class="summary"><?php echo substr(strip_tags($topic->topic_news_content), 0,200).'...'; ?></p>
                        </header>
                </article>
                <?php }} else echo "Không tìm thấy kết quả";?>
                <div id="moreTopic"> </div>
                <p class="more">
                <a id="showmore" href="javascript:showMore();">Xem tất cả các kết quả tìm kiếm</a>
                <span id="mainContentMore"></span>
                </p>
        </section>

        <section class="result ">
            <header>

                <h1>Bài liên quan</h1>

            </header>


            <article class="advertising">
                <p class="type">Tài trợ</p>
                <div class="cover" style="background-image: url(http://img.v3.news.zdn.vn.jpg)">
                    <a href="http://news.zing.vn/"></a>
                </div>
                <header>
                <h1>
                    <a href="http://news.zing.vn/search">
                        400.000 giáo viên và học sinh thi 'An toàn giao thông' 
                    </a>

                </h1>
                <time datetime="2014-02-25 16:00+0700"> 16:00 ngày 25/02/2014</time>
                <p class="cate">Sự kiện</p>
                <p class="summary">'An toàn giao thông' 
                cho hơn 400.000 thầy cô giáo và học sinh trung học.</p>
                </header>
            </article>

            <article class="">
                <p class="type"></p>
                <div class="cover" style="background-image: url(http://img.v3.news.zdn.vn/w480/Uploaded/Ycgmvlbp/2014_02_25/aidh.JPG)">
                    <a href="http://news.zing.vn/Thay-doi-to-chuc-thi-tot-nghiep-THPT-2014-post394515.html#search"></a>
                </div>
                <header>
                    <h1>
                        <a href="http://news.zing.vn/Thay-doi-to-chuc-thi-tot-nghiep-THPT-2014-post394515.html#search">
                        Thay đổi tổ chức thi tốt nghiệp THPT 2014
                        </a>

                    </h1>
                    <time datetime="2014-02-25 14:31+0700"> 14:31 ngày 25/02/2014</time>
                    <p class="cate">Giáo dục</p>
                    <p class="summary">“Năm 2014, thay vì Bộ quyết định và công bố tất cả 
                    các môn thi thì học sinh được tự chọn 2 trong 6 môn theo nguyện vọng cá 
                    nhân”, ông Mai Văn Trinh cho biết.</p>
                </header>
            </article>

            <p class="more">
            <a id="ctl00_mainContent_ctl01_hlMore"></a>
            <span id="ctl00_mainContent_ctl01_pager"></span>
            </p>
        </section>

</section>

<section class="sidebar">

        <div id="advR1" class="banner">
            <div style="height: 250px;" id="advR1_temp">
                    <script>
                        if ($(document).width() > 1000) {
                            vng_ads.showBannerR1();
                        }
                    </script>
                    <script type="text/javascript">
                        (function(d, s, id) {
                            var js, fjs = d.getElementsByTagName(s)[0];
                            if (d.getElementById(id)) {return;}
                            js = d.createElement(s);
                            js.type = 'text/javascript';
                            js.async=true;
                            js.id = id;
                            js.src = "http://static.adtimaserver.vn/resource/js/zads-base-mod.js";
                            fjs.parentNode.insertBefore(js, fjs);}(document, 'script', 'z2-jssdk'));
                    </script>
                <div z2-rendered="true" z2-zoneid="1735161297688288341" z2-width="300" z2-height="250" class="z2-zads-zone">
                    <div style="width: 300px; height: 250px;" z2-rendered="true" id="zadDiv_1735161297688288341" align="center">
                        <iframe src="javascript:void(parent.ZADS.M2.loadIFrame(this, document, '1735161297688288341', 300, 250,''))" marginheight="0" marginwidth="0" style="height: 250px; width: 300px;" id="zadIFrame_Base_1735161297688288341" frameborder="0" scrolling="no"></iframe>
                    </div>
                </div>
            </div>
        </div>
<div id="advR2" class="banner">
    <div style="height: 250px;" id="advR2_temp">
        <script>
        if ($(document).width() > 1000) {
        vng_ads.showBannerR2();
        }
        </script>
        <script type="text/javascript">
        (function(d, s, id) {
        var js, fjs = d.getElementsByTagName(s)[0];
        if (d.getElementById(id)) {return;}
        js = d.createElement(s);
        js.type = 'text/javascript';
        js.async=true;
        js.id = id;
        js.src = "http://static.adtimaserver.vn/resource/js/zads-base-mod.js";
        fjs.parentNode.insertBefore(js, fjs);}(document, 'script', 'z2-jssdk'));
        </script>
        <div z2-rendered="true" z2-zoneid="56458834532064424" z2-width="300" z2-height="250" class="z2-zads-zone">
            <div style="width: 300px; height: 250px;" z2-rendered="true" id="zadDiv_56458834532064424" align="center">
                    <iframe src="javascript:void(parent.ZADS.M2.loadIFrame(this, document, '56458834532064424', 300, 250,''))" marginheight="0" marginwidth="0" style="height: 250px; width: 300px;" id="zadIFrame_Base_56458834532064424" frameborder="0" scrolling="no"></iframe>
            </div>
        </div>
    </div>
</div>

<!-- End 123.vn -->


<!-- Start Box Sidebar -->

<section class="order-list">
        <header>
            <h1><a title="Đọc nhiều nhất">Đọc nhiều nhất</a></h1>
        </header>

        <?php
            if ($topicReadless):
                foreach ($topicReadless as $key=>$topic) {
        ?>
        <article>
            <span class="order"><?=$key+1?></span>
            <div class="cover" style="background-image: url(<?php echo $topic->topic_news_picture;?>)">
                <a href="<?=site_url('home/detail').'/'.$topic->topic_news_id?>"></a>
            </div>
            <header>
                <h1>
                <a href="<?=site_url('home/detail').'/'.$topic->topic_news_id?>">
                <?php echo $topic->topic_news_title;?>
                </a>
                <span class="social <?php echo $topic->top;?>" style="display: inline;"><?php echo $topic->top;?></span>
                </h1>
                <time datetime="<?=date('Y-m-d H:i:s', $topic->topic_news_date)?>"></time>
                <p class="cate"><?php 
                    //     $CI = & get_instance();
                    //     $CI->load->model('category_model');
                    //     $cate = $CI->category_model->getInfo($topic->category_id);
                    // echo $cate->category_name;?></p>
            </header>
        </article>
        <?php } endif;?>
</section>

<section style="display: block;" id="promotedposts">
        <header>
            <h1><a href="http://news.zing.vn/thi-truong/TTDN.html" title="Thông tin doanh nghiệp">Thông tin doanh nghiệp </a></h1>
        </header>

        <article>
            <div class="cover" style="background-image: url(http://img.v3.news.zdn.vn/w480/Uploaded/JAC2_N3/2014_02_25/Honda_Viet_Nam_to_chuc_cuoc_thi_1.jpg)">
            <a href="http://news.zing.vn/400000-giao-vien-va-hoc-sinh-thi-An-toan-giao-thong-post394602.html#search_sidebar.pr"></a>
            </div>
            <header>
            <h1>
            <a href="http://news.zing.vn/400000-giao-vien-va-hoc-sinh-thi-An-toan-giao-thong-post394602.html#search_sidebar.pr">
            400.000 giáo viên và học sinh thi 'An toàn giao thông' 
            </a>

            </h1>
            </header>
        </article>

        <article>
            <div class="cover" style="background-image: url(http://img.v3.news.zdn.vn/w480/Uploaded/JAC1_N3/2014_02_25/iphone4s64gbwhite2_g257_0.jpg)">
            <a href="http://news.zing.vn/iPhone-4-va-4s-gia-tot-do-FPT-phan-phoi-post394493.html#search_sidebar.pr"></a>
            </div>
            <header>
            <h1>
            <a href="http://news.zing.vn/iPhone-4-va-4s-gia-tot-do-FPT-phan-phoi-post394493.html#search_sidebar.pr">
            iPhone 4 và 4s giá tốt do FPT phân phối
            </a>

            </h1>
            </header>
        </article>

        <article style="display: block;">
            <div class="cover" style="background-image: url(http://img.v3.news.zdn.vn/w480/Uploaded/JAC2_N3/2014_02_24/Sinh_vien_BUV_thuc_tap_tai_cong_ty_chung_khoan_Sai_Gon_1.jpg)">
            <a href="http://news.zing.vn/Thach-thuc-va-co-hoi-khi-theo-hoc-Tai-chinh--ngan-hang-post394301.html#search_sidebar.pr"></a>
            </div>
            <header>
            <h1>
            <a href="http://news.zing.vn/Thach-thuc-va-co-hoi-khi-theo-hoc-Tai-chinh--ngan-hang-post394301.html#search_sidebar.pr">
            Thách thức và cơ hội khi theo học Tài chính - ngân hàng
            </a>

            </h1>
            </header>
        </article>

</section>
<script>
    var posts = $('#promotedposts article');
    if ($(posts).length <= 5) {
        $('#promotedposts article').show();
        $('#promotedposts').show();
    } else {
        var display = [];
        while (display.length < 5) {
            i = Math.floor(Math.random() * $(posts).length);
            if (display.indexOf(i) == -1) display.push(i);
        }
        for (var i = 0, j = display.length; i < j; i++) {
        $($(posts)[display[i]]).show();
        };
        $('#promotedposts').show();
    }
</script>

</section>

</section>